package com.woniuxy.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.woniuxy.dao.BasicMapper;
import com.woniuxy.dao.CustLostMapper;
import com.woniuxy.dao.CustomerMapper;
import com.woniuxy.pojo.Basic;
import com.woniuxy.pojo.CustLost;
import com.woniuxy.pojo.Customer;
import com.woniuxy.service.BasicService;
import com.woniuxy.service.CustomerService;
import com.woniuxy.util.DataGridView;
import com.woniuxy.vo.BasicVo;
import com.woniuxy.vo.CustLostVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class BasicServiceImpl implements BasicService {
    @Autowired
    private BasicMapper basicMapper;
//根据条件查询基础数据
    @Override
    public DataGridView selectCondition(BasicVo basicVo) {
        Page<Object> page=PageHelper.startPage(basicVo.getPage(),basicVo.getLimit());
        List<Basic> basics=basicMapper.selectCondition(basicVo);
        return new DataGridView(page.getTotal(),basics);
    }

    //查询所有数据
    @Override
    public DataGridView selectAllBasicData(BasicVo basicVo) {
       Page<Object> page= PageHelper.startPage(basicVo.getPage(),basicVo.getLimit());
        List<Basic> basics=basicMapper.selectAll();
        return new DataGridView(page.getTotal(),basics);
    }
   //根据条件修改基本数据
    @Override
    public void updateBasicByCondition(Basic basic) {
        basicMapper.updateBasicByCondition(basic);
    }
    //根据编号查询，用于新增的时候去重
    @Override
    public Basic selectByNo(Basic basic) {
        return basicMapper.selectByNo(basic);
    }
//批量删除
    @Override
    public void deleteBatches(int[] basiNos) {
    if(basiNos.length>0&&basiNos!=null){
        for(int basiNo:basiNos){
            basicMapper.deleteByNo(basiNo);
        }
    }
    }

    //删除
    @Override
    public void deleteByNo(int basiNo) {
        basicMapper.deleteByNo(basiNo);
    }

    //新增基础数据
    @Override
    public int insertBasicData(Basic basic) {
        return basicMapper.insertBasicData(basic);
    }

    @Override
    public List<Basic> selectAllAres() {
        return basicMapper.selectAllAres();
    }
    @Override
    public List<Basic> selectAllGrade() {
        return basicMapper.selectAllGrade();
    }



}
